<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ScoreRecord extends BaseModel
{
	//
	public $timestamps = false;

	/**
	 * 添加积分变动记录
	 * @param $userId
	 * @param $preScore 变动之前的积分
	 * @param int $score 变动的积分
	 * @param int $type 1足彩相关，2,3其他
	 * @return bool
	 */
	public static function addRecord($userId, $preScore, $score = 1, $remark='',$type = 1)
	{
		$record = new ScoreRecord();
		$record->user_id = $userId;
		$record->pre_score = $preScore;
		$record->score = $score;
		$record->type = $type;
		$record->remark = $remark;
		$record->created_at = date('Y-m-d H:i:s');
		$res = $record->save();
		return $res ? true : false;
	}
}
